<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\helpers\HtmlPurifier;
use yii\captcha\Captcha;
use yii\widgets\ActiveForm;
use frontend\models\operate\User;
	$session = yii::$app->session;
	$user_id = $session->get('user_id');
	if(!empty($user_id))
	{
		$user = User::find()->select("user_id,user_name,user_thumb")->where("user_id=$user_id")->asarray()->one();
	}
	else
	{
		$user = "";
	}
	
?>
<link rel="stylesheet" href="/static/css/public-same.css" />
<link rel="stylesheet" href="/static/css/question.css" />
<style>
	.iPhone-num .ipt{width:100px; float:left;padding:10px;}
</style>
<!-- main-area -->
<div class="main-area QA-area" style=" background: #f5f5f5;">
<div class="container">
<div class="column-layout">
<!-- main-area-left start  -->
<div style="" class="column-col main-area-left">
		<div style="" class="main-area-leftin">
			<!-- 面包屑 -->
			<ol class="breadcrumb">
				<li>
					
						<a href="<?= Url::to(['operate/index'])?>">行业资讯</a>
					
				</li>
				<li class="active">文章详情</li>
			</ol>
			<!-- 正文 -->
			<div class="article-text-box" style="word-break: break-all">
				<h1><?= Html::encode($artlist['article_title'])?></h1>
				<div class="article-about">
					<div class="col-left">
						<span class="u-name"><?= Html::encode($artlist['article_author'])?></span>
						<span class="u-datetime">
					<?php  
                        $dur = time()-$artlist['article_addtime'];
                        /*暂时没想到怎么做、先做成这样的*/
                        if($dur<60){
                            echo $dur."秒前";
                        }else{
                            if($dur<3600){
                                echo floor($dur/60)."分钟前";
                            }else{
                                if($dur<86400){
                                    echo floor($dur/3600)."小时前";
                                }else{
                                    if($dur<604800){
                                        echo floor($dur/86400)."天前";
                                    }else{
                                        if($dur<2592000){
                                            echo floor($dur/604800)."周前";
                                        }else{
                                            if($dur<31104000){
                                                echo floor($dur/2592000)."月前";
                                            }else{
                                                if($dur>31104000){
                                                    echo floor($dur/31104000)."年前";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        echo $year;
                    ?>

						</span><span class="hot-tag-group"><a class="hot-tag" href="javascript:void(0)" target="_blank"><?= Html::encode($artlist['artlable_name'])?></a></span>

						<a href="javascript:;"><span class='collect' id="<?= Html::encode($artlist['article_id'])?>" >收藏</span></a>
					</div>
				</div>
			<br>
			
				<div id="article" style="word-break:break-all">
					<?= Html::encodejavascript($artlist['article_contents'])?>
				</div>
			
				<div class="article-foot">
					<div class="col-left">
						<span class="fun-btn" style="cursor: auto;">
							<!-- <i class="ico ico-share"></i> -->
							<span class="ico-label-text" style="vertical-align: top;">上一篇
									<div class="jiathis_style">
										<a href="<?= Url::to(['operate/detail'])?>?article_id=<?= Html::encode($prev['article_id'])?>"><?= Html::encode($prev['article_title'])?></a>
									</div>
							</span>
							<!-- <span class="ico-label-text" style="vertical-align: top;">分享到
								<div class="share-ibox" style="display:inline-block;vertical-align: top;">
									<div class="jiathis_style">
										<a title="分享到QQ空间" class="jiathis_button_qzone"><span class="jiathis_txt jtico jtico_qzone"></span></a>
										<a title="分享到新浪微博" class="jiathis_button_tsina"><span class="jiathis_txt jtico jtico_tsina"></span></a>
										<a title="分享到腾讯微博" class="jiathis_button_tqq"><span class="jiathis_txt jtico jtico_tqq"></span></a>
										<a title="分享到微信" class="jiathis_button_weixin"><span class="jiathis_txt jtico jtico_weixin"></span></a>
										<a title="分享到人人网" class="jiathis_button_renren"><span class="jiathis_txt jtico jtico_renren"></span></a>
									</div>
								</div>
							</span> -->
						</span>

						
						<!-- <ul class="list-inline u-group">
							
						</ul> -->
					</div>
					<div class="col-right">
						<?php if(!empty($next)){?>
						<span class="praise-btn"><i class="icon  icon-good"></i>
							
							<span class="ico-label-text" style="vertical-align: bottom">下一篇
								<div class="jiathis_style">
									<a href="<?= Url::to(['operate/detail'])?>?article_id=<?= Html::encode($next['article_id'])?>"><?= Html::encode($next['article_title'])?></a>
								</div>
							</span>

						</span>

						<?php }?>

						
						
						
					</div>
				</div>
			</div>

			<!-- 评论 -->
<div class="ibox" >
	<div class="ibox-head" style="border-bottom: 1px solid #ececec;">
		<div class="ibox-tit-text" style="width: 458px;float: left;">
			<h3 class="active-item">评论</h3>
                
		</div>
		<div class="bshare-custom icon-medium-plus" style="float: right;">
        	<span class="ico-label-text" style="vertical-align: top; font-size:18px">分享到:</span>
            <a class="bshare-weixin" data-cnd="weixin" title="分享到微信"></a>

            <a title="分享到QQ空间" class="bshare-qzone"></a>

            <a title="分享到新浪微博" class="bshare-sinaminiblog"></a>

            <a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a>
        </div>
        <script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh"></script>
        <script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>
	</div>
	<div style="" class="ibox-body">
		<div style="" class="comment-list">
			<!-- reply  -->
			
			<div style="" class="item reply-box">
			<?php if(empty($user)){?>
				<div class="col-left">
					<div class="col-in">
					
						<div class="u-photo-box">
							<a href="javascript:void(0)" class="u-photo" id="73826">
								<img src="/static/images/b6118494-4345-11e5-a876-00163e02100b_big.jpg" alt="" height="50" width="50">
								
							</a>
							<p></p>
						</div>
					</div>
				</div>
				<div style="" class="col-right">
					<div style="" class="col-in comm-reply-box comment-input">
						<div class="edui-default" id="comment1" style="width: 100%;">
						<?php $form = ActiveForm::begin()?>
						<textarea style="width: 100%; height: 100px;padding: 10px;" name="comment_content" placeholder="发表回答"></textarea>
						<div class="comm-reply-foot">
						<?= $form->field($model, 'verifyCode', [
						        'options' => ['class' => ''],
						    ])->widget(Captcha::className(),[
						       'template' => '<p class="iPhone-num">{image}<span class="img-num">{input}</span></p>',
						       'imageOptions' => ['alt' => '验证码'],
						       'captchaAction' => 'operate/captcha',
						       'options' =>['placeholder' => '请输入验证码', 'class' => 'ipt'],
						    ]); ?>
						    <input type="hidden" name="article_id" value="<?= Html::encode($artlist['article_id'])?>">
							<input id="main-reply" class="btn btn-micv5 btn-lg-fts submit-reply reply" parent_id="0" value="回答" type="button">
							&nbsp; &nbsp;<span style="color:red;display:none;">至少3个字</span>
						
						
						</div>
						<?php $form = ActiveForm::end()?>
						</div>
					</div>
				</div>		
					<?php }else{?>	
				<div class="col-left">
					<div class="col-in">	
						<div class="u-photo-box">
							<a href="<?= Url::to(['center/index'])?>" class="u-photo" id="73826">
								<img src="http://files.bwphp.com/file/image/show/50/50?path=<?= Html::encode($user['user_thumb'])?>" alt="" height="50" width="50">
								
							</a>
							<p><?= Html::encode($user['user_name'])?></p>
						</div>
					</div>
				</div>
				<div style="" class="col-right">
					<div style="" class="col-in comm-reply-box comment-input">
						<div class="edui-default" id="comment1" style="width: 100%;">
						<?php $form = ActiveForm::begin([
								'action' => ['operate/comment'],
								'method'=>'post',
						])?>
						<textarea style="width: 100%; height: 100px;padding: 10px;" name="comment_content" placeholder="发表回答"></textarea>
						<div class="comm-reply-foot">
						<?= $form->field($model, 'verifyCode', [
						        'options' => ['class' => ''],
						    ])->widget(Captcha::className(),[
						       'template' => '<p class="iPhone-num">{image}<span class="img-num">{input}</span></p>',
						       'imageOptions' => ['alt' => '验证码'],
						       'captchaAction' => 'operate/captcha',
						       'options' =>['placeholder' => '请输入验证码', 'class' => 'ipt'],
						    ]); ?>
						    <input type="hidden" name="article_id" value="<?= Html::encode($artlist['article_id'])?>">
							<input id="main-reply" class="btn btn-micv5 btn-lg-fts reply" parent_id="0" value="回答" type="submit">
							&nbsp; &nbsp;<span style="color:red;display:none;">至少3个字</span>
						
						
						</div>
						<?php $form = ActiveForm::end()?>
						</div>
					</div>
				</div>	
					<?php }?>	
				
			</div>
			
		</div>
	</div>

	<div class="ibox-body zy_comment">
		<div class="comment-list">
			<!-- item  -->
			<div id="comments">
				<!--这里放异步加载的评论内容-->
				<?php foreach ($release as $key => $reply) {?>                            
        <div class="item">
    <div class="col-left">
        <div class="col-in">
            <div class="u-photo-box">
                <a href="javescript:void(0);" target="_blank" class="u-photo u-photo-btn" id="67912">
                    <img width="50" height="50" src="http://files.bwphp.com/file/image/show/50/50?path=<?= Html::encode($reply['user_thumb'])?>" alt="">
                </a>
                
            </div>
            <div class="text-center">
                
            </div>
        </div>
    </div>
    <div class="col-right">
        <div class="col-in comm-main">
            <div class="comm-about">
                <span class="u-name"><?= Html::encode($reply['user_name'])?><!-- <span class="u-status">老师</span> --></span>
                <span class="u-datetime">
                    <?php  
                        $dur = time()-$reply['comment_addtime'];
                        /*暂时没想到怎么做、先做成这样的*/
                        if($dur<60){
                            echo $dur."秒前";
                        }else{
                            if($dur<3600){
                                echo floor($dur/60)."分钟前";
                            }else{
                                if($dur<86400){
                                    echo floor($dur/3600)."小时前";
                                }else{
                                    if($dur<604800){
                                        echo floor($dur/86400)."天前";
                                    }else{
                                        if($dur<2592000){
                                            echo floor($dur/604800)."周前";
                                        }else{
                                            if($dur<31104000){
                                                echo floor($dur/2592000)."月前";
                                            }else{
                                                if($dur>31104000){
                                                    echo floor($dur/31104000)."年前";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        echo $year;
                    ?>
                </span>
                <?php if($reply['answer_best']==1){?>
                <span style="float:right">最佳</span>
                <?php }?>
            </div>
            <div class="comm-cnt zy_shou11" style="max-width: 693px; word-break:break-all">
                <p><?= Html::encode($reply['comment_content'])?></p><!--<p>查看更多</p>-->
            </div>
            <div class="comm-fun">
                <span class="fun-btn comm-reply-btn" parent_id="30011" target_box="reply-box-30011" child_id="30011" u_name="O桑"><!-- 回复 --></span>
                <span class="fun-btn praise-btn ">
                    <i class="ico ico-good"></i>
                    <span class="ico-label-text">0</span>
                </span>
            </div>
        </div>
        
        
        
        
        
        
    </div>
</div>
<?php }?>
			</div>
		</div>
		<!-- <p id="load_message" class="text-center no-message">沙发空缺中，还不快抢！</p> -->

		<input value="0" id="loadmore_page" hidden="hidden">
	</div>
</div>



		</div>
	</div>
<!-- main-area-left end  -->
<!-- main-area-right start  -->
<?php echo $this->render('commen')?>
<!-- main-area-right end  -->
</div>
</div>
</div>
</div>
<div class="modal fade" id="likeTwice" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm" style="top:150px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" style="font-size: 18px;">消息提示</h4>
            </div>
            <div class="modal-body">
                <section class="box-login v5-input-txt" id="box-login">
                        <center><h4 style="font-size: 18px;margin-bottom: 20px;">您已收藏，不能再收藏了！</h4>
                        <button data-dismiss="modal"  style="width: 150px;" type="button" class="btn btn-micv5 btn-block">确定</button></center>
                        
                </section>
            </div>
        </div>
    </div>
</div>
<script>
    $(".submit-reply").click(function(){
        login_popup()
    })
    //收藏
    $(document).on('click','.collect',function(){
        var id = $(this).attr('id');
        $.ajax({
            type : "get",
            url : "<?php echo Url::to(['operate/collect']);?>",
            data : 'id='+id,
            dataType : 'json',
            success: function(msg){
                if(msg.code == 1){
                    jq('#loginModal').modal('show');
                }else if(msg.code == 2){
                    //不能重复喜欢
                    jq('#likeTwice').modal('show');
                }else if(msg.code == 3){
                    //喜欢成功
                    //thiss.replaceWith()
                    alert(msg.msg)
                }else if(msg.code == 4){
                    alert(msg.msg)
                }
            }
        });
    })
</script>